/* Exercise 5.36
   ejer5_36.c */
#include <stdio.h>

void hanoi(int disks, int initial, int destiny, int auxiliar);

/* function main begins program execution */
int main( void )
{
    int disks;

    printf("Enter the number of the disks: ");
    scanf("%d", &disks);

    hanoi(disks, 1, 3, 2);
	return 0; /* indicate that program ended successfully */
} /* end function main */

/* This is a recursive function that solves the Hanoi problem */
void hanoi(int disks, int initial, int destiny, int auxiliar)
{
    if (disks > 0)
    {
        hanoi(disks - 1, initial, auxiliar, destiny);
        printf("%d -> %d\n", initial, destiny);
        hanoi(disks - 1, auxiliar, destiny, initial);
    }
}
